<?php
header("Content-Type: text/html; charset=iso-8859-1");
require 'include.php';
$text = (!empty($_REQUEST['value'])) ? $_REQUEST['value'] : "";
$check = (!empty($_REQUEST['check'])) ? $_REQUEST['check'] : "";
$marqueur = (!empty($_REQUEST['marqueur'])) ? $_REQUEST['marqueur'] : "";
$arbitre = (!empty($_REQUEST['arbitre'])) ? $_REQUEST['arbitre'] : "";
$arbitre_junior = (!empty($_REQUEST['arbitre_junior'])) ? $_REQUEST['arbitre_junior'] : "";
if($text){
	$text = utf8_decode($text);
	$tab = split(" ",$text);
	if(count($tab) == 1){
		$text = addslashes($text);
		$q = "select * from membres where (nom like '$text%' or prenom like '$text%') and valide = 1 and fictif = 0";
	}
	else{
		$q = "select * from membres where ((nom like '".(addslashes($tab[0]))."%' and prenom like '".(addslashes($tab[1]))."%') or (prenom like '".(addslashes($tab[0]))."%' and nom like '".(addslashes($tab[1]))."%')) and valide = 1 and fictif = 0";
	}
	if($marqueur) $q .= " and marqueur = 1";
	if($arbitre) $q .= " and arbitre = 1";
	if($arbitre_junior) $q .= " and arbitre_junior = 1";
	$r = ExecRequete($q);
	if($check && mysql_num_rows($r) == 1){
		$s = LigneSuivante($r);
		echo $s->id;
	}
	elseif($check && mysql_num_rows($r) != 1){
		echo "";
	}
	elseif(mysql_num_rows($r)){
		echo "<ul>";
		while($s = LigneSuivante($r)){
			echo "<li>".(CapitalizeLastName($s->prenom))." ".(CapitalizeLastName($s->nom))."</li>";
		}
		echo "</ul>";
	}
	else echo "<ul><li class = 'italic fade'>$text</li></ul>";
}
	else echo "<ul><li class = 'italic fade'>$text</li></ul>";
?>